﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Entidades;

namespace AccesoBD
{
    public class DiasSemana
    {
        public static List<DiaSemana> obtenerTodosDiaSemana()
        {
            List<DiaSemana> list;
            SqlConnection conexion = DB.Conectar();
            try
            {
                string comando = "SELECT codDiaSemana, nombre FROM Dia_Semana WHERE codDiaSemana <> 1 AND codDiaSemana <> 7";
                SqlCommand sqlcmd = new SqlCommand(comando, conexion);
                SqlDataReader dr = sqlcmd.ExecuteReader();

                list = new List<DiaSemana>();
                DiaSemana objDS = null;
                while (dr.Read())
                {
                    objDS = new DiaSemana();
                    objDS.CodDiaSemana = int.Parse(dr["codDiaSemana"].ToString());
                    objDS.Nombre = dr["nombre"].ToString();

                    list.Add(objDS);
                    objDS = null;
                }
            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                conexion.Close();
            }
            return list;
        }
    }
}
